{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In this lab we'll go beyond standard data analysis and actually code a machine learning algorithm from scratch. As this is our first such exercise we'll start with a classic linear model, Logistic Regression. We'll accomplish this with the following steps:\n",
    "\n",
    "1. Build a class that can fit a Logistic Regression given training data as well as make predictions on examples without labels\n",
    "2. Write a unit test that confirms our class produces the correct estimates on synthetically generated data\n",
    "3. Benchmark our class against SkLearn for speed and accuracy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# A Logistic Class"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Before we do any programming, we need to first understand the optimization algorithm we'll use. As a reference, we'll be following the presentation presented here: https://tminka.github.io/papers/logreg/minka-logreg-old.pdf.\n",
    "\n",
    "The logistic loss is convex so we'll use a convex optimization process called gradient descent. In particular, we will use a variant called Newton's Method that uses the 2nd derivative of the loss function to set the learning rate. To start, here are some primitives:\n",
    "\n",
    "<b>$L = \\sum y * ln(p) + (1-y)*ln(1-p)$</b>\n",
    "\n",
    "(Note, we'll drop subscripts over the data instances to keep notation simple. All sums are over examples in the data set.)\n",
    "\n",
    "<b> $g_j = \\nabla L_j = \\sum (y-p)*x_j$</b>\n",
    "\n",
    "(This is the 1st derivative, where $j$ indicates feature dimension $j$)\n",
    "\n",
    "<b> $H_{jk} = \\sum p*(1-p)*x_j*x_k$</b>\n",
    "\n",
    "(This is the 2nd derivative w.r.t. features $j$ and $k$)\n",
    "\n",
    "Now the general form of Gradient Descent follows this function:\n",
    "\n",
    "<b>$w_{new} = w_{old} - \\nu * g$</b>\n",
    "\n",
    "Where $w$ is the weight and $\\nu$ is an appropriately chosen step size. In our case, we're going to use the inverse of the 2nd derviative matrix (the Hessian) as our learning rate. If we define $H$ as the Hessian matrix with entries $H_{jk}$ from above, and $G$ a gradient vector who's $jth$ entry is $g_j$, then our optimization problem becomes:\n",
    "\n",
    "<b>$w_{new} = w_{old} - H^{-1} * G$</b>\n",
    "\n",
    "This is what we are going to program here. Let's define a class that has the following methods:\n",
    "\n",
    "1. An __init__ method that takes in an error tolerence as a stopping criterion, as well as max number of iterations.\n",
    "2. A <b>predict</b> method that takes a given matrix X and predicts $p=(1+e^{(-X*B)})^{-1}$ for each entry\n",
    "3. A <b>compute_gradient</b> method that computes the gradient vector $G$\n",
    "4. A <b>compute_hessian</b> method that computes the Hessian. Note that the $H$ can be broken down to the following matrix multiplcation: $H=X^TQX$, where $X$ is the input matrix and $Q$ is a diagonal matrix where each entry $Q_{ii}=p_i*(1-p_i)$.\n",
    "5. An <b>update_weights</b> method that applies Newton's method to update the weights\n",
    "6. A <b>check_stop</b> method that checks whether the model has converged or the max iterations have been met\n",
    "7. A <b>fit</b> method that takes in the data and runs the gradient optimization\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#write a class with the following API\n",
    "import numpy as np\n",
    "\n",
    "\n",
    "class MyFirstLogReg(object):\n",
    "    \n",
    "    def __init__(self, tol = 10**-8, max_iterations = 20):\n",
    "        \n",
    "        self.tolerance = tol\n",
    "        self.max_iterations = max_iterations\n",
    "        self.beta = None\n",
    "        self.alpha = 0\n",
    "        \n",
    "    def predict(self, Xint):\n",
    "        '''\n",
    "        Compute probs using the inverse logit\n",
    "        - Inputs: The NxK X matrix\n",
    "        - Outputs: Vector of probs of length N\n",
    "        '''\n",
    "        \n",
    "        #First compute X*beta+alpha\n",
    "        XB = Xint.dot(self.b) \n",
    "        return (1+np.exp(-1*XB))**-1\n",
    "        \n",
    "    def compute_gradient(self, Xint, y, p):\n",
    "        '''\n",
    "        Computes the gradient vector\n",
    "        -Inputs:\n",
    "            - NxK X matrix\n",
    "            - Nx1 y (label) vector\n",
    "            - Nx1 ps vector of predictions\n",
    "        -Outputs: 1xK vector of gradients\n",
    "        '''\n",
    "        return (y-p).dot(Xint)\n",
    "        \n",
    "    def compute_hessian(self, Xint, P):\n",
    "        '''\n",
    "        computes the Hessian matrix\n",
    "        -inputs:\n",
    "            - NxK X matrix\n",
    "            - Nx1 vector of predictions\n",
    "        -outputs:\n",
    "            - KxK Hessian matrix H=X^T * Diag(Q) * X\n",
    "        '''\n",
    "        #Note, in first \n",
    "        Q = np.diag(P*(1-P))\n",
    "        return (Xint.T).dot(Q).dot(Xint)\n",
    "\n",
    "\n",
    "    def update_weights(self, Xint, y, i):\n",
    "        '''\n",
    "        Updates existing weight vector\n",
    "        -Inputs:\n",
    "            -NxK X matrix\n",
    "            -Nx1 y vector\n",
    "        -updates weights by calling predict, compute_gradient and compute_hessian\n",
    "        '''\n",
    "        p = self.predict(Xint)\n",
    "        g = self.compute_gradient(Xint, y, p)\n",
    "        H = self.compute_hessian(Xint, p)\n",
    "                \n",
    "        #Store the current weights before updating so we can check for convergence\n",
    "        self.prior_b = self.b\n",
    "        \n",
    "        #update the weights\n",
    "        self.b = self.b + np.linalg.inv(H).dot(g)\n",
    "        \n",
    "        \n",
    "    def check_stop(self):\n",
    "        '''\n",
    "        check to see if euclidean distance between old and new weights (normalized)\n",
    "        is less than the tolerance\n",
    "        \n",
    "        returns: True or False on whether stopping criteria is met\n",
    "        '''\n",
    "        b_old_norm = self.prior_b / (np.sqrt(self.prior_b.dot(self.prior_b)))\n",
    "        b_new_norm = self.b / (np.sqrt(self.b.dot(self.b)))\n",
    "        diff = b_new_norm - b_old_norm\n",
    "        return (np.sqrt(diff.dot(diff)) < self.tolerance)\n",
    "        \n",
    "        \n",
    "    def fit(self, X, y):\n",
    "        '''\n",
    "        X is the Nx(K-1) data matrix\n",
    "        Y is the labels, using {0,1} coding\n",
    "        '''\n",
    "        \n",
    "        #set initial weights - add an extra dimension for the intercept\n",
    "        self.b = np.zeros(X.shape[1] + 1)\n",
    "        \n",
    "        #Initialize the slope parameter to log(base rate/(1-base rate))\n",
    "        self.b[-1] = np.log(y.mean() / (1-y.mean()))\n",
    "        \n",
    "        #create a new X matrix that includes a column of ones for the intercept\n",
    "        Xint = np.hstack((X, np.ones((X.shape[0],1))))\n",
    "\n",
    "        for i in range(self.max_iterations):\n",
    "            #print(i)\n",
    "            self.update_weights(Xint, y, i)\n",
    "            self.beta = self.b[0:-1]\n",
    "            self.alpha = self.b[-1]\n",
    "            if self.check_stop():\n",
    "                break\n",
    "            \n",
    "        "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note about testing\n",
    "\n",
    "One way we can test this implementation is to generate some random data according to a logistic model, and see if our model returns the correct weights. To do this:\n",
    "\n",
    "\n",
    "* generate an NxK X matrix of random numbers\n",
    "* generate a 1xK weight vector called Beta\n",
    "* set alpha\n",
    "* Given Beta and Alpha, compute P(Y|X) using the logistic function\n",
    "* Generate an Nx1 random sequence in [0,1], and set Y=1 if R_i < P_i\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#Generate a dataset with N=10k and K=5\n",
    "def gen_logistic(N, K, Beta, Alpha):\n",
    "    X = np.random.random((N,K))\n",
    "    XB = X.dot(Beta) + Alpha * np.ones(N)\n",
    "    P = (1 + np.exp(-1*XB))**-1\n",
    "    Y = (np.random.random(N) < P)\n",
    "    return X, Y\n",
    "\n",
    "K = 2\n",
    "\n",
    "Beta = 2*(np.random.random(K)-1)\n",
    "Alpha = -1\n",
    "\n",
    "X, Y = gen_logistic(1000, K, Beta, Alpha)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now that we have our dataset, let's test out our algorithm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "lr = MyFirstLogReg()\n",
    "lr.fit(X, Y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The real Betas and Alpha are:\n",
      "[-1.84180703 -0.20277473] -1\n",
      "\n",
      "The fitted Betas and Alpha are:\n",
      "[-1.64438904 -0.41202617] -1.1480464234681091\n"
     ]
    }
   ],
   "source": [
    "print('The real Betas and Alpha are:')\n",
    "print(Beta, Alpha)\n",
    "print('')\n",
    "print('The fitted Betas and Alpha are:')\n",
    "print(lr.beta, lr.alpha)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "Now let's compare our fitted results to SkLearn's Logistic Regression implementation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([[-1.64438881, -0.41202617]]), array([-1.14804636]))"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.linear_model import LogisticRegression\n",
    "\n",
    "LR_SK = LogisticRegression(C=10**10).fit(X,Y)\n",
    "LR_SK.coef_, LR_SK.intercept_"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can see that this is pretty close, though not exact at all digits of precision.  We can also see that both systems produce estimates that are far from the truth. Does this mean that the code is correct? If it is indeed correct, why might we observe the above? We can write a more robust test by running multiple draws, and seeing if on average we get the right answer. We can also increase the sample size. Doing either will be more computationally expensive. Before going there let's profile our code to see if there is a way to optimize it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "         226 function calls in 0.028 seconds\n",
      "\n",
      "   Ordered by: standard name\n",
      "\n",
      "   ncalls  tottime  percall  cumtime  percall filename:lineno(function)\n",
      "        5    0.000    0.000    0.000    0.000 <ipython-input-1-5667aecc335f>:14(predict)\n",
      "        5    0.000    0.000    0.000    0.000 <ipython-input-1-5667aecc335f>:25(compute_gradient)\n",
      "        5    0.000    0.000    0.022    0.004 <ipython-input-1-5667aecc335f>:36(compute_hessian)\n",
      "        5    0.004    0.001    0.027    0.005 <ipython-input-1-5667aecc335f>:50(update_weights)\n",
      "        5    0.000    0.000    0.000    0.000 <ipython-input-1-5667aecc335f>:69(check_stop)\n",
      "        1    0.000    0.000    0.028    0.028 <ipython-input-1-5667aecc335f>:82(fit)\n",
      "        1    0.000    0.000    0.028    0.028 <string>:1(<module>)\n",
      "        2    0.000    0.000    0.000    0.000 _methods.py:48(_count_reduce_items)\n",
      "        2    0.000    0.000    0.000    0.000 _methods.py:58(_mean)\n",
      "        5    0.000    0.000    0.000    0.000 linalg.py:103(get_linalg_error_extobj)\n",
      "        5    0.000    0.000    0.000    0.000 linalg.py:108(_makearray)\n",
      "       10    0.000    0.000    0.000    0.000 linalg.py:113(isComplexType)\n",
      "        5    0.000    0.000    0.000    0.000 linalg.py:126(_realType)\n",
      "        5    0.000    0.000    0.000    0.000 linalg.py:141(_commonType)\n",
      "        5    0.000    0.000    0.000    0.000 linalg.py:200(_assertRankAtLeast2)\n",
      "        5    0.000    0.000    0.000    0.000 linalg.py:211(_assertNdSquareness)\n",
      "        5    0.000    0.000    0.001    0.000 linalg.py:468(inv)\n",
      "        1    0.000    0.000    0.000    0.000 numeric.py:156(ones)\n",
      "        5    0.000    0.000    0.000    0.000 numeric.py:433(asarray)\n",
      "        9    0.000    0.000    0.000    0.000 numeric.py:504(asanyarray)\n",
      "        2    0.000    0.000    0.000    0.000 shape_base.py:11(atleast_1d)\n",
      "        1    0.000    0.000    0.000    0.000 shape_base.py:236(hstack)\n",
      "        1    0.000    0.000    0.000    0.000 shape_base.py:283(<listcomp>)\n",
      "        5    0.000    0.000    0.009    0.002 twodim_base.py:197(diag)\n",
      "        5    0.000    0.000    0.000    0.000 {built-in method builtins.abs}\n",
      "        1    0.000    0.000    0.028    0.028 {built-in method builtins.exec}\n",
      "        5    0.000    0.000    0.000    0.000 {built-in method builtins.getattr}\n",
      "        2    0.000    0.000    0.000    0.000 {built-in method builtins.hasattr}\n",
      "        4    0.000    0.000    0.000    0.000 {built-in method builtins.isinstance}\n",
      "       17    0.000    0.000    0.000    0.000 {built-in method builtins.issubclass}\n",
      "        7    0.000    0.000    0.000    0.000 {built-in method builtins.len}\n",
      "       14    0.000    0.000    0.000    0.000 {built-in method numpy.core.multiarray.array}\n",
      "        1    0.000    0.000    0.000    0.000 {built-in method numpy.core.multiarray.concatenate}\n",
      "        1    0.000    0.000    0.000    0.000 {built-in method numpy.core.multiarray.copyto}\n",
      "        1    0.000    0.000    0.000    0.000 {built-in method numpy.core.multiarray.empty}\n",
      "        6    0.008    0.001    0.008    0.001 {built-in method numpy.core.multiarray.zeros}\n",
      "        5    0.000    0.000    0.000    0.000 {method '__array_prepare__' of 'numpy.ndarray' objects}\n",
      "        2    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}\n",
      "        5    0.000    0.000    0.000    0.000 {method 'astype' of 'numpy.ndarray' objects}\n",
      "        1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}\n",
      "       40    0.014    0.000    0.014    0.000 {method 'dot' of 'numpy.ndarray' objects}\n",
      "        5    0.000    0.000    0.000    0.000 {method 'get' of 'dict' objects}\n",
      "        2    0.000    0.000    0.000    0.000 {method 'mean' of 'numpy.ndarray' objects}\n",
      "        2    0.000    0.000    0.000    0.000 {method 'reduce' of 'numpy.ufunc' objects}\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import cProfile\n",
    "cProfile.run('lr.fit(X, Y)')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "What method is taking the most amount of time? Looking more closely at the exact sequence of operations, what might be taking up a lot of memory or time? How can we achieve the same mathematic results, but do it in a more memory friendly way?\n",
    "\n",
    "Let's do a quick test, where we design an alternative, and hopefully faster way to compute the Hessian."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## This is a good place to break. Part 2 in the next lab"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def hessian_slow(X, P):\n",
    "    '''\n",
    "    Copy the operations used in the class above\n",
    "    '''\n",
    "    Q = np.diag(P*(1-P))\n",
    "    return (X.T).dot(Q).dot(X)\n",
    "    \n",
    "    \n",
    "def hessian_fast(X, P):\n",
    "    '''\n",
    "    Rewrite this without using the np.diag function\n",
    "    '''\n",
    "    Q = P*(1-P)\n",
    "    XQ = X.T * Q\n",
    "    return XQ.dot(X)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "100 loops, best of 3: 3.49 ms per loop\n"
     ]
    }
   ],
   "source": [
    "P = 0.5 * np.ones(X.shape[0])\n",
    "%timeit hessian_slow(X, P)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The slowest run took 14.29 times longer than the fastest. This could mean that an intermediate result is being cached.\n",
      "10000 loops, best of 3: 21.4 µs per loop\n"
     ]
    }
   ],
   "source": [
    "%timeit hessian_fast(X, P)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Does this make a difference? Now create a new class, same as above, but overwrite the compute_hessian method with the above faster version. We're going to do this in a very light and efficient way. Essentially we'll inherit MyFirstLogReg class, which means all of the methods in the base class are callable for this one. We can overwrite the compute_hessian method with our faster approach (note, in normal software development we'd likely just revise the original class, but we're doing it this way to show the example)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "\n",
    "class MyFasterFirstLogReg(MyFirstLogReg):\n",
    "    \n",
    "    def compute_hessian(self, Xint, p):\n",
    "        '''\n",
    "        computes the Hessian matrix\n",
    "        -inputs:\n",
    "            - NxK X matrix\n",
    "            - Nx1 vector of predictions\n",
    "        -outputs:\n",
    "            - KxK Hessian matrix H=X^T * Diag(Q) * X\n",
    "        '''\n",
    "        Q = p*(1-p)\n",
    "        XintQ = Xint.T * Q\n",
    "        return XintQ.dot(Xint)\n",
    "\n",
    "\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#Now rerun\n",
    "lr = MyFasterFirstLogReg()\n",
    "lr.fit(X, Y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([-1.64438904, -0.41202617]), -1.1480464234681091)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lr.beta, lr.alpha"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As one last speed test, let's compare our faster class to sklearn."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1000 loops, best of 3: 856 µs per loop\n"
     ]
    }
   ],
   "source": [
    "%timeit LogisticRegression().fit(X,Y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1000 loops, best of 3: 782 µs per loop\n"
     ]
    }
   ],
   "source": [
    "%timeit MyFasterFirstLogReg().fit(X, Y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now that we've got an efficient class written, let's perform 3 different unit tests:\n",
    "* Compare the results to SkLearn. This replicates a scenario where for some reason we can't use the SkLearn package and had to write our own code. Since SkLearn does exist, we can at least benchmark against it.\n",
    "* Run it once just on a much larger data set (which should come close to the truth value).\n",
    "* Run it many times over different draws from the same data generating distribution and look at the distribution of outcomes."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#First let's generate a dataset with 1000000 examples\n",
    "K = 4\n",
    "Beta = 2*(np.random.random(K)-1)\n",
    "Alpha = -2\n",
    "\n",
    "X, Y = gen_logistic(1000000, K, Beta, Alpha)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "LR_SK = LogisticRegression(C=10**30).fit(X,Y)\n",
    "LR_Mine = MyFasterFirstLogReg()\n",
    "LR_Mine.fit(X, Y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Truth: beta=[[-0.44567075 -1.42752653 -0.22013092 -1.85578601]], Alpha=-2\n",
      "SkLearn: beta=[[-0.44567075 -1.42752653 -0.22013092 -1.85578601]], Alpha=-2\n",
      "Ours: beta=[-0.44566344 -1.42750999 -0.22013456 -1.85580747], Alpha=-2.0060087546764263\n"
     ]
    }
   ],
   "source": [
    "print('Truth: beta=' + str(LR_SK.coef_) + ', Alpha=' +str(Alpha))\n",
    "print('SkLearn: beta=' + str(LR_SK.coef_) + ', Alpha=' +str(Alpha))\n",
    "print('Ours: beta=' + str(LR_Mine.beta) + ', Alpha=' +str(LR_Mine.alpha))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For this test we'll check whether on average our own LR class is correct. To do this, run a loop where in each iteration, generate a random data set of size N, using the same Beta and Alpha. Then fit the model and store the weights. After this runs we can look at the distributions of features."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "betas = []\n",
    "alphas = []\n",
    "\n",
    "for i in range(10000):\n",
    "    X, Y = gen_logistic(10000, K, Beta, Alpha)\n",
    "    LR_Mine = MyFasterFirstLogReg()\n",
    "    LR_Mine.fit(X, Y)\n",
    "    betas.append(LR_Mine.beta)\n",
    "    alphas.append(LR_Mine.alpha)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now plot the histograms of each parameter distribution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#First put it all in a dataframe\n",
    "import pandas as pd\n",
    "df = pd.DataFrame(betas, columns = ['b' + str(k) for k in range(K)])\n",
    "df['alpha'] = alphas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(b0      -0.452829\n",
       " b1      -1.459697\n",
       " b2      -0.212411\n",
       " b3      -1.845400\n",
       " alpha   -2.003525\n",
       " dtype: float64,\n",
       " array([-0.451672  , -1.45290954, -0.20970989, -1.84053181]),\n",
       " -2)"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Let's check the means against the truth\n",
    "df.mean(), Beta, Alpha"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAskAAAHiCAYAAAAatlGFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAIABJREFUeJzs3XuYZFV97//3R0BMghGRCQeByaBi\nPJjE0UzUHKNB0YiYCJ6owXhBxYwmkOiJnjjiMZLECyZRfhojBsUA3oCgRhQ0IuIx5gg6EEQuGkdF\nmckAowKCIAp8f3/s1VBT9KW6u6q7uvv9ep56Ztfaa+/61u6aVd9ae+21U1VIkiRJuss9FjsASZIk\nadyYJEuSJEl9TJIlSZKkPibJkiRJUh+TZEmSJKmPSbIkSZLUxyR5CUhyZZInLn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f+mef\n3/jsjR3FpQm2amsj4hXAbwHnZOZmicB5wBfqbf+s+4EuYqrV8aMRcTXVYeGbgGna587i6Xpf2UFM\nne4ju8gnisHqUct1DFaP2hi6HrXQa641jdENtyhjTt4DfCUz/7rx3q7ay98Gbh8yNja4dWtpLG6g\nGgcMsBfo+t/SgbLeNut/GY3DSutlV8r3Qrotuy1ji4iT1ocqRMQpwK8BXx6g7NrEdjxwNfC+zLyq\n8V7X5dbm9r/1mF8KfKaU0wHg4qiufnE6cCbwn3PGM1VsEfFs4J3ABZl5tDZ/4vYdOLZ6+3AB1dg6\nqI6ovLjEeBLVCUj1oywaUEScC/wpVR3a6pyJDduyopP9QJuYIuLxEfHE9WmqerT+3dO0z13FM+i+\nsuV2W+Q+cjOD1KM2hqxHLeMZY841nnqUPZ4V2HxQFfJ9wEPAEeCTZf5TgWvL9NlUXfu3AbeWx/nl\nvfcDXyrvHQB2DRlbeX0+1dmfd1P1Oq7PP4MqYTkI/DNwQsdl92TgeuAu4NPAyWX+GvDu2nK7qf5Z\nPabx+c+Usrsd+ADwhCFjA361fP8Xy/MlQ5Rdy9heDvywVt9uBc7qq9wm1SGqIRwXlOnHlXI4WMrl\njNpn31Q+dydwXpd1rGVsny6/j/VyOrDV9h0wtj8H7igx3AD8fO2zryrleRB4Zdex+ZhqOx6kGm+4\nXofWr+TSbGsfT9Vz9KTG5zvfD7SJqbRTXyyPO3h0+z+xnek5nkH3lVNst0H2kbTfZw9Zj9rkOEPW\no9HlXFNst4XkWs2Hd9yTJEmSGkY33EKSJElaNJNkSZIkqcEkWZIkSWowSZYkSZIaTJIlSZKkBpNk\nSZIkqcEkWZIkSWowSZYkSZIa/h8oNZIxvfbiUgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 1200x800 with 4 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "\n",
    "bmeans = df.mean()\n",
    "fig = plt.figure(figsize=(12,8))\n",
    "for i in range(K):\n",
    "    fig.add_subplot(2,2,i+1)\n",
    "    plt.hist(df['b'+str(i)], bins=100)\n",
    "    plt.plot()\n",
    "    plt.title('b {}: Fit={}, Truth={}'.format(i, np.round(bmeans[i],2), np.round(Beta[i],2)))\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [py35]",
   "language": "python",
   "name": "Python [py35]"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
